{include file="common:lay_header" / }
{include file="common:upload" / }
<body>
<form class="layui-form" action="" lay-filter="example">
    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input type="text" name="title" lay-verify="required" value="{$info.title}" autocomplete="off" placeholder="请输入标题" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">来源</label>
        <div class="layui-input-inline">
            <select name="source" lay-verify="required" lay-search="">
                <option value="">直接选择或搜索选择</option>
                {volist name="source" id="data"}
                {eq name="$data.label" value="$info.source"}
                    <option value="{$data.value}" selected>{$data.label}</option>
                {else/}
                    <option value="{$data.value}">{$data.label}</option>
                {/eq}
                {/volist}
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">时间</label>
        <div class="layui-input-block">
            <input type="text" name="create_time" value="{$info.create_time|date='Y-m-d H:i:s'}" lay-verify="required" autocomplete="off" placeholder="格式：2020-01-01 12:00:00" class="layui-input">
        </div>
    </div>

    <div class="layui-upload">
        <label class="layui-form-label">图片上传</label>
        <button type="button" class="layui-btn" id="test1">上传图片</button>
        <div class="layui-upload-list">
            <img class="layui-upload-img" id="demo1" width="20%" src="{$info.image}">
            <p id="demoText"></p>
        </div>
        <input type="hidden" id="test2" name="image">
    </div>



    <script type="text/javascript" src="/static/index/js/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" src="/ueditor/ueditor.all.min.js"></script>
    <script type="text/javascript" src="/ueditor/lang/zh-cn/zh-cn.js"></script>

    <div class="layui-form-item">
        <label class="layui-form-label">详情</label>
        <div class="layui-input-block">
            <textarea id="demo" style="display: block;" name="content">{$info.content}</textarea>
            <script type="text/javascript">
                UE.getEditor('demo',{initialFrameWidth:800,initialFrameHeight:300})
            </script>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-block">
            <input type="text" name="sort" value="{$info.sort}"  autocomplete="off" placeholder="请输入排序" class="layui-input">
        </div>
    </div>

    <input type="hidden" name="id" value="{$info.id}">
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
        </div>
    </div>
</form>


<script src="__LAYUI__/layui.js" charset="utf-8"></script>

<script>
    layui.use(['upload','form','layedit'], function(){
        var $ = layui.jquery
            ,upload = layui.upload
            ,form = layui.form
            //,layedit = layui.layedit;


        //普通图片上传
        one_upload(upload,$);
       //var index =  layedit.build('demo'); //建立编辑器;
        //监听提交
        form.on('submit(demo1)', function(data){

            let json_field = data.field;
            //json_field.content = layedit.getContent(index);
            let url = "{:url('update')}";
            let params = json_field;
            console.log(params)
            _axios(url,params)
            return false;
        });
    });
</script>

</body>
</html>